package com.gticket.cinemauser.service.impl;

import com.gticket.cinemauser.mapper.UsersMapper;
import com.gticket.cinemauser.pojo.Users;
import com.gticket.cinemauser.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UsersMapper usersMapper;

    @Value("${server.port}")
    private String port;

    /**
     * 查询用户是否存在
     * @param user user对象，需传入账号、影院名
     * @return users对象
     */
    @Override
    public Users findUserByAccount(Users user) {
        Users userResult = usersMapper.selectUserByUser_name(user);
        return userResult;
    }

    /**
     * 将注册的用户信息插入用户表
     * @param user  要插入的用户信息
     * @return int 受影响行数
     */
    @Override
    public int register(Users user) {
        int row = usersMapper.addUser(user);
        return row;
    }

    /**
     * 通过用户名查询用户
     * @param user user对象
     * @return Users
     */
    @Override
    public Users findUserByUser_name(Users user) {

        Users resultUser = usersMapper.selectUserByUser_name(user);
        return resultUser;
    }

}
